<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/xhtml;charset=UTF-8"/>
<meta http-equiv="X-UA-Compatible" content="IE=9"/>
<meta name="generator" content="Doxygen 1.8.8"/>
<title>embedme: libemb/inc/Network.h 源文件</title>
<link href="tabs.css" rel="stylesheet" type="text/css"/>
<script type="text/javascript" src="jquery.js"></script>
<script type="text/javascript" src="dynsections.js"></script>
<link href="doxygen.css" rel="stylesheet" type="text/css" />
</head>
<body>
<div id="top"><!-- do not remove this div, it is closed by doxygen! -->
<div id="titlearea">
<table cellspacing="0" cellpadding="0">
 <tbody>
 <tr style="height: 56px;">
  <td id="projectlogo"><img alt="Logo" src="logo.png"/></td>
  <td style="padding-left: 0.5em;">
   <div id="projectname">embedme
   </div>
  </td>
 </tr>
 </tbody>
</table>
</div>
<!-- end header part -->
<!-- 制作者 Doxygen 1.8.8 -->
  <div id="navrow1" class="tabs">
    <ul class="tablist">
      <li><a href="index.html"><span>首页</span></a></li>
      <li><a href="annotated.html"><span>类</span></a></li>
      <li class="current"><a href="files.html"><span>文件</span></a></li>
    </ul>
  </div>
  <div id="navrow2" class="tabs2">
    <ul class="tablist">
      <li><a href="files.html"><span>文件列表</span></a></li>
      <li><a href="globals.html"><span>文件成员</span></a></li>
    </ul>
  </div>
<div id="nav-path" class="navpath">
  <ul>
<li class="navelem"><a class="el" href="dir_574d9269cd334a9d02d8928365303d98.html">libemb</a></li><li class="navelem"><a class="el" href="dir_207aad82934689048a9003fb51f06f7f.html">inc</a></li>  </ul>
</div>
</div><!-- top -->
<div class="header">
  <div class="headertitle">
<div class="title">Network.h</div>  </div>
</div><!--header-->
<div class="contents">
<a href="_network_8h.html">浏览该文件的文档.</a><div class="fragment"><div class="line"><a name="l00001"></a><span class="lineno">    1</span>&#160;<span class="comment">/******************************************************************************</span></div>
<div class="line"><a name="l00002"></a><span class="lineno">    2</span>&#160;<span class="comment"> * This file is part of libemb.</span></div>
<div class="line"><a name="l00003"></a><span class="lineno">    3</span>&#160;<span class="comment"> *</span></div>
<div class="line"><a name="l00004"></a><span class="lineno">    4</span>&#160;<span class="comment"> * libemb is free software: you can redistribute it and/or modify</span></div>
<div class="line"><a name="l00005"></a><span class="lineno">    5</span>&#160;<span class="comment"> * it under the terms of the GNU General Public License as published by</span></div>
<div class="line"><a name="l00006"></a><span class="lineno">    6</span>&#160;<span class="comment"> * the Free Software Foundation, either version 3 of the License, or</span></div>
<div class="line"><a name="l00007"></a><span class="lineno">    7</span>&#160;<span class="comment"> * (at your option) any later version.</span></div>
<div class="line"><a name="l00008"></a><span class="lineno">    8</span>&#160;<span class="comment"> *</span></div>
<div class="line"><a name="l00009"></a><span class="lineno">    9</span>&#160;<span class="comment"> * libemb is distributed in the hope that it will be useful,</span></div>
<div class="line"><a name="l00010"></a><span class="lineno">   10</span>&#160;<span class="comment"> * but WITHOUT ANY WARRANTY; without even the implied warranty of</span></div>
<div class="line"><a name="l00011"></a><span class="lineno">   11</span>&#160;<span class="comment"> * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the</span></div>
<div class="line"><a name="l00012"></a><span class="lineno">   12</span>&#160;<span class="comment"> * GNU General Public License for more details.</span></div>
<div class="line"><a name="l00013"></a><span class="lineno">   13</span>&#160;<span class="comment"> *</span></div>
<div class="line"><a name="l00014"></a><span class="lineno">   14</span>&#160;<span class="comment"> * You should have received a copy of the GNU General Public License</span></div>
<div class="line"><a name="l00015"></a><span class="lineno">   15</span>&#160;<span class="comment"> * along with libemb.  If not, see &lt;http://www.gnu.org/licenses/&gt;.</span></div>
<div class="line"><a name="l00016"></a><span class="lineno">   16</span>&#160;<span class="comment"> *</span></div>
<div class="line"><a name="l00017"></a><span class="lineno">   17</span>&#160;<span class="comment"> * Project: Embedme</span></div>
<div class="line"><a name="l00018"></a><span class="lineno">   18</span>&#160;<span class="comment"> * Author : FergusZeng</span></div>
<div class="line"><a name="l00019"></a><span class="lineno">   19</span>&#160;<span class="comment"> * Email  : cblock@126.com</span></div>
<div class="line"><a name="l00020"></a><span class="lineno">   20</span>&#160;<span class="comment"> * git    : https://git.oschina.net/cblock/embedme</span></div>
<div class="line"><a name="l00021"></a><span class="lineno">   21</span>&#160;<span class="comment"> * Copyright 2014 @ ShenZhen ,China</span></div>
<div class="line"><a name="l00022"></a><span class="lineno">   22</span>&#160;<span class="comment">*******************************************************************************/</span></div>
<div class="line"><a name="l00023"></a><span class="lineno">   23</span>&#160;<span class="preprocessor">#ifndef __NETWORK_H__</span></div>
<div class="line"><a name="l00024"></a><span class="lineno">   24</span>&#160;<span class="preprocessor">#define __NETWORK_H__</span></div>
<div class="line"><a name="l00025"></a><span class="lineno">   25</span>&#160;</div>
<div class="line"><a name="l00026"></a><span class="lineno">   26</span>&#160;<span class="preprocessor">#ifdef OS_NONUNIX</span></div>
<div class="line"><a name="l00027"></a><span class="lineno">   27</span>&#160;<span class="preprocessor">#else</span></div>
<div class="line"><a name="l00028"></a><span class="lineno">   28</span>&#160;<span class="preprocessor">#include &quot;<a class="code" href="_base_type_8h.html">BaseType.h</a>&quot;</span></div>
<div class="line"><a name="l00029"></a><span class="lineno">   29</span>&#160;<span class="preprocessor">#include&lt;iostream&gt;</span></div>
<div class="line"><a name="l00030"></a><span class="lineno">   30</span>&#160;</div>
<div class="line"><a name="l00037"></a><span class="lineno"><a class="line" href="class_i_n_t_f.html">   37</a></span>&#160;<span class="keyword">class </span><a class="code" href="class_i_n_t_f.html">INTF</a>{</div>
<div class="line"><a name="l00038"></a><span class="lineno">   38</span>&#160;<span class="keyword">public</span>:</div>
<div class="line"><a name="l00039"></a><span class="lineno"><a class="line" href="class_i_n_t_f.html#a69cf5de00d8f772a32e83a50b1a3bc3d">   39</a></span>&#160;    <span class="keyword">static</span> <span class="keyword">const</span> sint32 <a class="code" href="class_i_n_t_f.html#a69cf5de00d8f772a32e83a50b1a3bc3d">DOWN</a>=0; </div>
<div class="line"><a name="l00040"></a><span class="lineno"><a class="line" href="class_i_n_t_f.html#a0545d09c7e586ab5e28dc91a3882d652">   40</a></span>&#160;    <span class="keyword">static</span> <span class="keyword">const</span> sint32 <a class="code" href="class_i_n_t_f.html#a0545d09c7e586ab5e28dc91a3882d652">UP</a>=1;   </div>
<div class="line"><a name="l00041"></a><span class="lineno">   41</span>&#160;};</div>
<div class="line"><a name="l00042"></a><span class="lineno">   42</span>&#160;</div>
<div class="line"><a name="l00043"></a><span class="lineno"><a class="line" href="_network_8h.html#ab57f33ca164d10e1b21c58faed61d868">   43</a></span>&#160;<span class="keyword">typedef</span> <span class="keyword">enum</span>{</div>
<div class="line"><a name="l00044"></a><span class="lineno"><a class="line" href="_network_8h.html#ab57f33ca164d10e1b21c58faed61d868aac57188d889b6e06078ee734a83d54e8">   44</a></span>&#160;    <a class="code" href="_network_8h.html#ab57f33ca164d10e1b21c58faed61d868aac57188d889b6e06078ee734a83d54e8">INTF_LINK_DOWN</a> = 0,   </div>
<div class="line"><a name="l00045"></a><span class="lineno"><a class="line" href="_network_8h.html#ab57f33ca164d10e1b21c58faed61d868abe03d86608c7a78d80adbdac3b3cb016">   45</a></span>&#160;    <a class="code" href="_network_8h.html#ab57f33ca164d10e1b21c58faed61d868abe03d86608c7a78d80adbdac3b3cb016">INTF_LINK_UP</a>,       </div>
<div class="line"><a name="l00046"></a><span class="lineno">   46</span>&#160;}<a class="code" href="_network_8h.html#ab57f33ca164d10e1b21c58faed61d868">INTF_LINK_STATUS</a>;</div>
<div class="line"><a name="l00053"></a><span class="lineno"><a class="line" href="class_network.html">   53</a></span>&#160;<span class="keyword">class </span><a class="code" href="class_network.html">Network</a>{</div>
<div class="line"><a name="l00054"></a><span class="lineno">   54</span>&#160;<span class="keyword">public</span>:</div>
<div class="line"><a name="l00055"></a><span class="lineno">   55</span>&#160;    <a class="code" href="class_network.html">Network</a>();</div>
<div class="line"><a name="l00056"></a><span class="lineno">   56</span>&#160;    ~<a class="code" href="class_network.html">Network</a>();</div>
<div class="line"><a name="l00057"></a><span class="lineno">   57</span>&#160;    <span class="keyword">static</span> <span class="keywordtype">bool</span> isValidIP(<span class="keyword">const</span> std::string ip);</div>
<div class="line"><a name="l00058"></a><span class="lineno">   58</span>&#160;    std::string getSubnetIP(<span class="keyword">const</span> std::string gatewayIP,<span class="keyword">const</span> std::string subnetMask,sint32 subIndex);</div>
<div class="line"><a name="l00059"></a><span class="lineno">   59</span>&#160;    <span class="keyword">static</span> std::string <a class="code" href="class_network.html#a32387be250c452d4753104c35feef396">getInetAddr</a>(<span class="keyword">const</span> std::string intf);</div>
<div class="line"><a name="l00060"></a><span class="lineno">   60</span>&#160;    <span class="keyword">static</span> std::string <a class="code" href="class_network.html#ac5383fcfa9c6e1ca9054023764dd8bc1">getMaskAddr</a>(<span class="keyword">const</span> std::string intf);</div>
<div class="line"><a name="l00061"></a><span class="lineno">   61</span>&#160;    <span class="keyword">static</span> std::string <a class="code" href="class_network.html#a398762dc97e710378366dc7644332a99">getMacAddr</a>(<span class="keyword">const</span> std::string intf);</div>
<div class="line"><a name="l00062"></a><span class="lineno">   62</span>&#160;    <span class="keyword">static</span> sint32 <a class="code" href="class_network.html#a5be3dd99aaae9dfd86ea2460b5e17514">getIfUpDown</a>(<span class="keyword">const</span> std::string intf);</div>
<div class="line"><a name="l00063"></a><span class="lineno">   63</span>&#160;    <span class="keyword">static</span> sint32 <a class="code" href="class_network.html#ae34c41b000df924c0d2ec597f1299786">setInetAddr</a>(<span class="keyword">const</span> std::string intf,<span class="keyword">const</span> std::string ipaddr);</div>
<div class="line"><a name="l00064"></a><span class="lineno">   64</span>&#160;    <span class="keyword">static</span> sint32 <a class="code" href="class_network.html#a17fb128c761e6aa129818ac29eb01852">setMaskAddr</a>(<span class="keyword">const</span> std::string intf,<span class="keyword">const</span> std::string netmask);</div>
<div class="line"><a name="l00065"></a><span class="lineno">   65</span>&#160;    <span class="keyword">static</span> sint32 <a class="code" href="class_network.html#aa6bf9ae4135cdd1941a4af0d153b69f4">setMacAddr</a>(<span class="keyword">const</span> std::string intf,<span class="keyword">const</span> std::string mac);</div>
<div class="line"><a name="l00066"></a><span class="lineno">   66</span>&#160;    <span class="keyword">static</span> sint32 <a class="code" href="class_network.html#a28633da6000b20a86816b11b1f6b2a8b">setIfUpDown</a>(<span class="keyword">const</span> std::string intf, sint32 upOrDown);</div>
<div class="line"><a name="l00067"></a><span class="lineno">   67</span>&#160;    <span class="keyword">static</span> std::string <a class="code" href="class_network.html#a2c8eac1c0493e3a2748e3a2f23586978">dhcpClientGetIP</a>(<span class="keyword">const</span> std::string intf);</div>
<div class="line"><a name="l00068"></a><span class="lineno">   68</span>&#160;    <span class="keyword">static</span> sint32 checkSubnetIP(<span class="keyword">const</span> std::string gatewayIP,<span class="keyword">const</span> std::string subnetMask,std::string&amp; subnetIP);</div>
<div class="line"><a name="l00069"></a><span class="lineno">   69</span>&#160;    <span class="keyword">static</span> sint32 getIfLinkUpDown(<span class="keyword">const</span> std::string intf);</div>
<div class="line"><a name="l00070"></a><span class="lineno">   70</span>&#160;};</div>
<div class="line"><a name="l00071"></a><span class="lineno">   71</span>&#160;</div>
<div class="line"><a name="l00072"></a><span class="lineno">   72</span>&#160;<span class="preprocessor">#endif</span></div>
<div class="line"><a name="l00073"></a><span class="lineno">   73</span>&#160;<span class="preprocessor">#endif</span></div>
<div class="ttc" id="_network_8h_html_ab57f33ca164d10e1b21c58faed61d868aac57188d889b6e06078ee734a83d54e8"><div class="ttname"><a href="_network_8h.html#ab57f33ca164d10e1b21c58faed61d868aac57188d889b6e06078ee734a83d54e8">INTF_LINK_DOWN</a></div><div class="ttdef"><b>Definition:</b> Network.h:44</div></div>
<div class="ttc" id="class_i_n_t_f_html_a69cf5de00d8f772a32e83a50b1a3bc3d"><div class="ttname"><a href="class_i_n_t_f.html#a69cf5de00d8f772a32e83a50b1a3bc3d">INTF::DOWN</a></div><div class="ttdeci">static const sint32 DOWN</div><div class="ttdef"><b>Definition:</b> Network.h:39</div></div>
<div class="ttc" id="class_network_html_a32387be250c452d4753104c35feef396"><div class="ttname"><a href="class_network.html#a32387be250c452d4753104c35feef396">Network::getInetAddr</a></div><div class="ttdeci">static std::string getInetAddr(const std::string intf)</div><div class="ttdoc">获取网口ip地址 </div><div class="ttdef"><b>Definition:</b> Network.cpp:91</div></div>
<div class="ttc" id="class_network_html_a2c8eac1c0493e3a2748e3a2f23586978"><div class="ttname"><a href="class_network.html#a2c8eac1c0493e3a2748e3a2f23586978">Network::dhcpClientGetIP</a></div><div class="ttdeci">static std::string dhcpClientGetIP(const std::string intf)</div><div class="ttdoc">dhcp动态获取ip地址 </div><div class="ttdef"><b>Definition:</b> Network.cpp:428</div></div>
<div class="ttc" id="_network_8h_html_ab57f33ca164d10e1b21c58faed61d868"><div class="ttname"><a href="_network_8h.html#ab57f33ca164d10e1b21c58faed61d868">INTF_LINK_STATUS</a></div><div class="ttdeci">INTF_LINK_STATUS</div><div class="ttdef"><b>Definition:</b> Network.h:43</div></div>
<div class="ttc" id="class_network_html_a17fb128c761e6aa129818ac29eb01852"><div class="ttname"><a href="class_network.html#a17fb128c761e6aa129818ac29eb01852">Network::setMaskAddr</a></div><div class="ttdeci">static sint32 setMaskAddr(const std::string intf, const std::string netmask)</div><div class="ttdoc">设置网口子网掩码地址 </div><div class="ttdef"><b>Definition:</b> Network.cpp:216</div></div>
<div class="ttc" id="class_network_html_ae34c41b000df924c0d2ec597f1299786"><div class="ttname"><a href="class_network.html#ae34c41b000df924c0d2ec597f1299786">Network::setInetAddr</a></div><div class="ttdeci">static sint32 setInetAddr(const std::string intf, const std::string ipaddr)</div><div class="ttdoc">设置网口ip地址 </div><div class="ttdef"><b>Definition:</b> Network.cpp:132</div></div>
<div class="ttc" id="class_network_html_a28633da6000b20a86816b11b1f6b2a8b"><div class="ttname"><a href="class_network.html#a28633da6000b20a86816b11b1f6b2a8b">Network::setIfUpDown</a></div><div class="ttdeci">static sint32 setIfUpDown(const std::string intf, sint32 upOrDown)</div><div class="ttdoc">设置网口状态 </div><div class="ttdef"><b>Definition:</b> Network.cpp:378</div></div>
<div class="ttc" id="class_network_html_a398762dc97e710378366dc7644332a99"><div class="ttname"><a href="class_network.html#a398762dc97e710378366dc7644332a99">Network::getMacAddr</a></div><div class="ttdeci">static std::string getMacAddr(const std::string intf)</div><div class="ttdoc">获取网口mac地址 </div><div class="ttdef"><b>Definition:</b> Network.cpp:259</div></div>
<div class="ttc" id="_network_8h_html_ab57f33ca164d10e1b21c58faed61d868abe03d86608c7a78d80adbdac3b3cb016"><div class="ttname"><a href="_network_8h.html#ab57f33ca164d10e1b21c58faed61d868abe03d86608c7a78d80adbdac3b3cb016">INTF_LINK_UP</a></div><div class="ttdef"><b>Definition:</b> Network.h:45</div></div>
<div class="ttc" id="class_i_n_t_f_html"><div class="ttname"><a href="class_i_n_t_f.html">INTF</a></div><div class="ttdoc">网口状态常量 </div><div class="ttdef"><b>Definition:</b> Network.h:37</div></div>
<div class="ttc" id="class_network_html_aa6bf9ae4135cdd1941a4af0d153b69f4"><div class="ttname"><a href="class_network.html#aa6bf9ae4135cdd1941a4af0d153b69f4">Network::setMacAddr</a></div><div class="ttdeci">static sint32 setMacAddr(const std::string intf, const std::string mac)</div><div class="ttdoc">设置网口mac地址 </div><div class="ttdef"><b>Definition:</b> Network.cpp:297</div></div>
<div class="ttc" id="class_i_n_t_f_html_a0545d09c7e586ab5e28dc91a3882d652"><div class="ttname"><a href="class_i_n_t_f.html#a0545d09c7e586ab5e28dc91a3882d652">INTF::UP</a></div><div class="ttdeci">static const sint32 UP</div><div class="ttdef"><b>Definition:</b> Network.h:40</div></div>
<div class="ttc" id="class_network_html_ac5383fcfa9c6e1ca9054023764dd8bc1"><div class="ttname"><a href="class_network.html#ac5383fcfa9c6e1ca9054023764dd8bc1">Network::getMaskAddr</a></div><div class="ttdeci">static std::string getMaskAddr(const std::string intf)</div><div class="ttdoc">获取网口子网掩码地址 </div><div class="ttdef"><b>Definition:</b> Network.cpp:176</div></div>
<div class="ttc" id="class_network_html"><div class="ttname"><a href="class_network.html">Network</a></div><div class="ttdoc">网络类,提供对网络设别的常用操作. </div><div class="ttdef"><b>Definition:</b> Network.h:53</div></div>
<div class="ttc" id="class_network_html_a5be3dd99aaae9dfd86ea2460b5e17514"><div class="ttname"><a href="class_network.html#a5be3dd99aaae9dfd86ea2460b5e17514">Network::getIfUpDown</a></div><div class="ttdeci">static sint32 getIfUpDown(const std::string intf)</div><div class="ttdoc">获取网口状态 </div><div class="ttdef"><b>Definition:</b> Network.cpp:338</div></div>
<div class="ttc" id="_base_type_8h_html"><div class="ttname"><a href="_base_type_8h.html">BaseType.h</a></div></div>
</div><!-- fragment --></div><!-- contents -->
<!-- start footer part -->
<hr class="footer"/><address class="footer"><small>
生成于 2016年 七月 7日 星期四 19:49:37 , 为 embedme使用  &#160;<a href="http://www.doxygen.org/index.html">
<img class="footer" src="doxygen.png" alt="doxygen"/>
</a> 1.8.8
</small></address>
</body>
</html>
